# xmind_utils.py
import os
import glob
from functools import lru_cache
from utils.file_dir import get_xmind_dir

def get_project_root():
    """获取项目根目录（即 apidemokeywordspyts 目录）"""
    return os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

@lru_cache(maxsize=1)
def get_all_xmind_files():
    """
    获取项目根目录下所有 .xmind 文件路径（包括子目录）
    返回：List[str]
    """
    root = get_project_root()
    pattern = os.path.join(root, "**", "*.xmind")
    return glob.glob(pattern, recursive=True)


def get_xmind_files_in_xmind_dir():
    xmind_dir = get_xmind_dir()
    pattern = os.path.join(xmind_dir, "*.xmind")
    return glob.glob(pattern, recursive=True)
